/**
 * Problem Statement
   Point: 250
 When dealing with long names and phrases, we sometimes use the initial letters of words to form its acronym. 
 For example, we use "JFK" instead of "John Fitzgerald Kennedy", "lgtm" instead of "looks good to me", and so on.
 You are given a String name.
 This String contains a phrase: 
   one or more words separated by single spaces. 

Please compute and return the acronym of this phrase. 
(As above, the acronym should consist of the first letter of each word, in order.)

 */
package org.yuwgle.srm.r698.d2;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 
 * @author Weicl
 *
 */
public class Initials {
	public String getInitials(String name) {
		StringBuilder sb = new StringBuilder();
		Pattern p = Pattern.compile("(\\w)[^\\s]+");
		Matcher m = p.matcher(name);
		
		while(m.find()) {
			sb.append(m.group(1));
		}
		
		return sb.toString();
	}
	
	public static void main(String[] args) {
		Initials in = new Initials();
		
		System.out.println(in.getInitials("John Fitzgerald Kennedy"));
		System.out.println(in.getInitials("looks good to me"));
	}
}
